<template>
    <el-dialog title="题目预览" :visible="shouYulan" @close="closeYulan" class="box1">
      <el-row class="left">
        <el-col :span="6"><div class="grid-content bg-purple">【题型】：{{ _questionType(yulanChuan.push.questionType) }}</div></el-col>
        <el-col :span="6"><div class="grid-content bg-purple-light">【编号】：{{ yulanChuan.push.id }}</div></el-col>
        <el-col :span="6"><div class="grid-content bg-purple">【难度】：{{ _difficulty(yulanChuan.push.difficulty) }}</div></el-col>
        <el-col :span="6"><div class="grid-content bg-purple-light">【标签】：{{ yulanChuan.push.tags }}</div></el-col>
      </el-row>
      <el-row class="left">
        <el-col :span="6"><div class="grid-content bg-purple">【学科】：{{ yulanChuan.push.subject }}</div></el-col>
        <el-col :span="6"><div class="grid-content bg-purple-light">【目录】：{{ yulanChuan.push.catalog }}</div></el-col>
        <el-col :span="6"><div class="grid-content bg-purple">【方向】：{{ yulanChuan.push.direction }}</div></el-col>
        <el-col :span="6"><div class="grid-content bg-purple-light"></div></el-col>
      </el-row>
      <div><hr></div>
      <el-row class="left">
        <el-col :span="24"><div class="grid-content bg-purple-dark">
          <p>【题干】:</p>
          <p v-html="yulanChuan.push.question"></p>
          <p>{{ _questionType(yulanChuan.push.questionType) }} 选项：（以下选中的选项为正确答案）</p>
          <el-checkbox v-model="checked1" class="boxs"></el-checkbox><br>
          <el-checkbox v-model="checked2" class="boxs"></el-checkbox><br>
          <el-checkbox v-model="checked3" class="boxs"></el-checkbox><br>
          <el-checkbox v-model="checked4" class="boxs"></el-checkbox><br>
          <el-checkbox v-model="checked5" class="boxs"></el-checkbox><br>
          </div>
        </el-col>
      </el-row>
      <hr><br>
      <!-- 视频区域 -->
      <div class="cankao">
        <span>【参考答案】: </span>
        <span><button class="shipin" @click="shouShipin = true">视频答案预览</button></span>
        <div class="shipins" v-if="shouShipin">
          <video :src="yulanChuan.push.videoURL" autoplay="autoplay" controls="controls" height="200px" loop="loop" ></video>
        </div>
      </div>
      <hr><br>
      <!-- 答案解析 -->
      <div>
        <span>【答案解析】： </span>
        <span v-html="yulanChuan.push.answer"></span>
      </div>
      <br><hr><br>
      <div>
        <span>【题目备注】： </span>
        <span>{{ yulanChuan.push.subject }}</span>
      </div>
    <!-- footer插槽 -->
    <template v-slot:footer>
      <el-button class="quxiao" right-footer type="primary" @click="closeYulan">取消</el-button>
    </template>
  </el-dialog>
</template>

<script>
// 引入假数据
import { difficulty, questionType } from '@/api/hmmm/constants'
export default {
  props: {
    shouYulan: {
      type: Boolean,
      default: false
    },
    yulanChuan: {
      type: Array
    }
  },
  data () {
    return {
      checked1: false,
      checked2: true,
      checked3: false,
      checked4: false,
      checked5: false,
      // 视频是否展示插件
      shouShipin: false
    }
  },
  methods: {
    // 取消按钮点击之后
    closeYulan () {
      this.$emit('clase-yulan', false)
      this.checked1 = false
      this.checked2 = true
      this.checked3 = false
      this.checked4 = false
      this.checked5 = false
      // 视频是否展示插件
      this.shouShipin = false
    },
    // 题型格式化
    _questionType (val) {
      const tixing = questionType
      const map = {}
      tixing.forEach(item => {
        map[item.value] = item.label
      })
      return map[val]
    },
    // 难度格式化
    _difficulty (val) {
      const nandu = difficulty
      const map = {}
      nandu.forEach(item => {
        map[item.value] = item.label
      })
      return map[val]
    }
  }
}
</script>

<style scoped lang="less">
.clearfix:after {
  visibility: hidden;
  clear: both;
  display: block;
  content: ".";
  height: 0;
}
.clearfix {
  *zoom: 1;
}
  .el-row {
    margin-bottom: 20px;
    &:last-child {
      margin-bottom: 0;
    }
  }
.left .grid-content {
    float: left;
  }
  .boxs {
    margin: 7px 0;
  }
.shipin {
  padding: 6px;
  background-color: rgb(223, 77, 77);
  border: 1px solid rgb(223, 77, 77);
  border-radius: 4px;
  color: rgb(243, 243, 243);
}
.shipin:focus {
  outline: none;
}
.shipins {
  widows: 300px;
  margin: 20px;
}
.quxiao {
  margin-left: 400px;
}
</style>
